package mess;

import java.util.Arrays;

public class LeeCode_2335 {
    public static void main(String[] args) {
        int[] amount = new int[]{5, 4, 4};
        System.out.println(fillCups(amount));
    }
    private static int fillCups(int[] amount) {
        int count = 0;
        while (amount[0] > 0 || amount[1] > 0 || amount[2] > 0){
            Arrays.sort(amount);
            if (amount[2] > 0 && amount[1] > 0){
                amount[2]--;
                amount[1]--;
                count++;
                continue;
            }
            if (amount[2] > 0){
                count += amount[2];
                break;
            }
        }
        return count;
    }
}
